package com.itcc.service;

import com.itcc.config.SpringConfig;
import com.itcc.domain.Book;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class BookServiceTest {

    @Autowired
    private BookService bookService;

    @Test
    public void testFindById() {
        Book book = bookService.findById(4);
        System.out.println(book);
    }

    @Test
    public void testSelectAll() {
        List<Book> books = bookService.selectAll();
        for (Book book : books) {
            System.out.println(book);
        }
    }

    @Test
    public void testSelectOther(){
        List<Book> books = bookService.selectOther("JavaEE");
        for (Book book : books){
            System.out.println(book);
        }
    }
}
